package com.wf.test_quartz_demo.controller;



import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wf.test_quartz_demo.bean.CommonResult;
import com.wf.test_quartz_demo.bean.QuartzJobVO;
import com.wf.test_quartz_demo.bean.RecordsParam;
import com.wf.test_quartz_demo.service.TestQuartzJobInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @Description: 测试任务调度
 */
@RestController
@RequestMapping("/quartz/")
@Slf4j
public class TestQuartzController {

    @Autowired
    TestQuartzJobInfoService  testQuartzJobInfoService;

    /**
     * 添加任务
     * @param param
     * @return
     */
    @PostMapping(path = "/add")
    @ResponseBody
    public CommonResult<String> addJob(@RequestBody RecordsParam param) {
      return   testQuartzJobInfoService.addJob(param);
    }


    /**
     * 暂停任务
     * @param param
     * @return
     */
    @PostMapping(path = "/pause")
    @ResponseBody
    public CommonResult<String> pauseJob(@RequestBody RecordsParam param) {
        return   testQuartzJobInfoService.pauseJob(param);
    }

    /**
     * 恢复任务
     * @param param
     * @return
     */
    @PostMapping(path = "/resume")
    @ResponseBody
    public CommonResult<String> resumeJob(@RequestBody  RecordsParam param) {
        return   testQuartzJobInfoService.resumeJob(param);
    }

    /**
     * 修改任务
     *
     */
    @PostMapping(path = "/update")
    @ResponseBody
    public CommonResult<String> updateJob(@RequestBody  RecordsParam param) {
        return   testQuartzJobInfoService.updateJob(param);
    }

    /**
     * 删除任务
     *
     */
    @PostMapping(path = "/delete")
    @ResponseBody
    public CommonResult<String> deleteJob(@RequestBody  RecordsParam param) {
        return   testQuartzJobInfoService.deleteJob(param);
    }

    /**
     * 查询任务
     */
    @PostMapping(path = "/query")
    @ResponseBody
    public CommonResult<List<QuartzJobVO>> queryJob(@RequestBody  RecordsParam param) {
        return   testQuartzJobInfoService.getJobAndTriggerDetails(param);

    }

}

